<%-- 
    Document   : reports
    Created on : Feb 27, 2013, 4:50:12 PM
    Author     : mona.chandrapal
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Reports</title>
<%@include file="header.jsp"%>


<style>
body .modal {
	/* new custom width */
	width: 750px;
	/* must be half of the width, minus scrollbar on the left (30px) */
	margin-left: -320px;
}

body .myalert {
	/* new custom width */
	width: 500px;
	/* must be half of the width, minus scrollbar on the left (30px) */
	margin-left: -240px;
}
</style>
</head>
<script>
	$(document).ready(
			function() {

				$.getJSON('../GetFeedback', function(data) {
					var i = 0;
					for (i = 0; i < data.feedback.length; i++) {

						$("#feedback").append(
								"<span  style=\"font-color: blue;\" >"
										+ data.feedback[i].feedback
										+ "</span>");
						$("#feedback").append(
								"<br><small><b> by </b><a>"
										+ data.feedback[i].user
										+ "</a><b> on </b>"
										+ data.feedback[i].date + "</small>");

						$("#feedback").append("<hr></br>");

					}
				});

			});

	$("#addfeedback").live('click', function() {
		$('#dlgfeedback').modal("show");
		return false;
	});

	$("#savefeedback").live(
			'click',
			function() {
				$.ajax({
					type : "post",
					url : "../SaveFeedback",
					datatype : "json",
					data : "feedback=" + $("#txtfeedback").val() + "&user="
							+ $("#uname").val(),
					success : function(data) {
						//alert("Thank You for your feedback");
						$('#dlgfeedback').modal('hide');

						$('#feedbacksaved').modal("show");
						$('#txtfeedback').html("");

						return false;
					},
					error : function(jqXHR, textStatus) {
						alert("Request failed: " + textStatus);
					}
				});
			});

	$("#ok").live('click', function() {

		$('#feedbacksaved').modal('hide');

		window.location = "sendFeedback.jsp";

	});
</script>


<body>
	<%@include file="toppanel.jsp"%>




	<input type='hidden' id='uname'
		value='<%=(String) session.getAttribute("user")%>' />


	<div style="width: 80%; padding-left: 10%">


		<div align="center" style="padding-top: 10px;">
			<input type="button" class="btn" style="padding: 20px;"
				id="addfeedback" value="Provide Feedback" />
		</div>
		<br /> <br /> <br />
		<div style="font-size: 16px;">
			<div id="feedback"></div>
		</div>

	</div>



	<div id="dlgfeedback" class="modal hide fade" style="display: none;">
		<div class="modal-header">
			<a href="#" class="close" data-dismiss="modal">x</a>
			<h4>Feedback:</h4>
		</div>
		<div class="modal-body">
			<textarea id="txtfeedback" rows="10" placeholder="Feedback..."
				class="input-block-level"></textarea>
		</div>
		<div class="modal-footer">
			<a href="#" class="btn confirm_delete_the_item no_return"
				id="savefeedback">Save</a> <a href="#" class="btn btn-secondary "
				data-dismiss="modal">Cancel</a>
		</div>
	</div>


	<div id="feedbacksaved" class="modal hide myalert"
		style="display: none;">
		<div class="modal-header">
			<a href="#" class="close" data-dismiss="modal">x</a>
			<h4>Feedback:</h4>
		</div>
		<div class="modal-body">
			<div class="alert alert-success">Thank You for your feedback.</div>

		</div>
		<div class="modal-footer">
			<a href="#" class="btn confirm_delete_the_item no_return" id="ok">OK</a>
		</div>
	</div>


</body>
</html>
